#ifndef __STREAMQUEUE__
#define __STREAMQUEUE__

typedef struct {
    size_t size; // header로 사용할 구조체에서 이것은 항상 있어야함.
    unsigned long long id;
    unsigned int magic;

}TESTHEADER;

typedef TESTHEADER HEADER;

typedef struct _SQ{
    unsigned char* buffer;
    size_t front, rear;
    size_t nextFront;

    size_t bufferSize;
    size_t min_available_size; //front/rear가 (bufferSize - min_available_size)를 넘어가면 다시 앞으로 온다.
    size_t max_unit_size;
}SQ;

void sq_init(SQ* sq);
void sq_updateRear(SQ* sq, size_t size);
int sq_updateFront(SQ* sq);
void sq_updateFrontDone(SQ* sq); //dequeue
int sq_full(SQ* sq);
size_t sq_emptySize(SQ* sq);

unsigned char* sq_rear(SQ* sq);
unsigned char* sq_front(SQ* sq);

#endif
